package com.zhdl.network.servertcp;

import cn.hutool.core.util.HexUtil;
import com.project.command.faq.queues.data.ControlInstructionPerformData;
import com.project.command.instruction.service.InstructionSendService;
import com.project.common.constant.Dic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static com.project.common.constant.Dic.HAND_AFTER_DEFAULT_SERVICE;
@Service
public class TcpServerSendService {
    @Autowired
    private InstructionSendService instructionSendService;
    public void sendCmd(String cmd){
        ControlInstructionPerformData data = new ControlInstructionPerformData();
        data.setInstruction(HexUtil.decodeHex(cmd));
        data.setPortKey("0.0.0.0:59152");
        data.setDstAdd(ServerTcpListener.RobotIP);
        data.setProtocols(Dic.HAND_MODBUS_RTU_ANALYSIS);
        data.setAfterInstructionName(HAND_AFTER_DEFAULT_SERVICE);
//        data.setAfterInstructionName(HandAfterDefaultService.HAND_AFTER_DEFAULT_SERVICE);
        data.setDataBit(10);
        data.setChain(cmd);
        instructionSendService.sendToClient(data);
    }
}
